package logic

import (
	"context"
	"goods_srv/elasticsearch"

	"goods_srv/goods"
	"goods_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetGoodsEsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetGoodsEsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGoodsEsLogic {
	return &GetGoodsEsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 获取es
func (l *GetGoodsEsLogic) GetGoodsEs(in *goods.GetGoodsEsRequest) (*goods.GetGoodsEsResponse, error) {
	// todo: add your logic here and delete this line

	goodsEs := elasticsearch.GetGoodsEs(in.Keyword)

	return &goods.GetGoodsEsResponse{
		List: goodsEs,
	}, nil
}
